package com.tjshop.android.model.tj.json;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.tjshop.android.model.BaseObject;
import com.tjshop.android.model.keyPair;

public class Category extends BaseObject {
	private int first_id;// "first_id":1,
	private String name;// "name":"中西药品",
	private String icon;// "icon":"http://220.178.101.93:8082/icons/andriod/class/1080/icon_class_xiyi.png",
	private int second_types;// "second_types":24,
	private ArrayList<SubCatagory> sublist = new ArrayList<SubCatagory>();

	public int getFirst_id() {
		return first_id;
	}

	public void setFirst_id(int first_id) {
		this.first_id = first_id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public int getSecond_types() {
		return second_types;
	}

	public void setSecond_types(int second_types) {
		this.second_types = second_types;
	}

	public ArrayList<SubCatagory> getSublist() {
		return sublist;
	}

	public void parse(JSONObject category) {
		setFirst_id(getInt(category, "first_id"));
		setIcon(getString(category, "icon"));
		setName(getString(category, "name"));
		setSecond_types(getInt(category, "second_types"));
		try {
			JSONArray array = category.getJSONArray("second_type");
			for (int i = 0; i < array.length(); i++) {
				SubCatagory sub = new SubCatagory();
				sub.parse(array.getJSONObject(i));
				sublist.add(sub);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void parse(JSONArray data) {
		// TODO Auto-generated method stub

	}

}
